<?php include 'init.php'; ?>
<?php $headertitle='Mario Kart Friend Code Registration'; include 'header.php'; ?>

			<table>
				<tr><td width="385px" valign="top">

					<div>					<b class="inbox">					<b class="inbox1"><b></b></b>					<b class="inbox2"><b></b></b>					<b class="inbox3"></b>					<b class="inbox4"></b>					<b class="inbox5"></b></b>					<div class="inboxfg">
					<table width="385px" cellpadding="0" cellspacing="0"><tr><td style="padding-left:5px"><h3>MARIO KART FRIEND CODE REGISTRATION</h3></td></tr></table>
										  	</div>  						<b class="inbox">  						<b class="inbox5"></b>  						<b class="inbox4"></b>  						<b class="inbox3"></b>  						<b class="inbox2"><b></b></b>  						<b class="inbox1"><b></b></b></b>						</div><p>
					<table width="385px" cellpadding="0" cellspacing="0"><tr><td style="padding-left:5px;padding-right:5px"><div id="regtext">We ask for your Wii Console Number incase you lose your password or to receive messages on your console when someone wants to race. You will need to add <span style=" font-size:12px"><strong>mii@mariokartchallenger.com</strong></span> to your Wii Address Book to enable this feature. <span style="font-size:12px"> ( <a href="how-to-receive-messages-on-your-wii.php""><strong>Video</strong></a> )</span><p></td></tr></table>					<div align="center">
					<?php 						 
						$query = "select * from user order by userid desc LIMIT 4";				    	$newusers = mysql_query($query);
						echo '<table cellspacing="0" cellpadding="0" style="padding-top:13px"><tr>';
						while($listem = mysql_fetch_array($newusers)){
							echo '<td><table style="padding-right:11px">
										<tr><td>	
											<img style="border: 1px solid black" src="avatar/'. $listem[racer]. '.jpg">
										</td></tr>
										<tr><td align="center">
											<span style="font-size:10px"><strong><a href="index.php?showuser=', $listem[userid], '" target="_blank">',$listem[nick],'</a><br />'. $listem[racevr] . '</span><span style="font-size:8px">VR</span></strong>
										</td></tr>
								  </table></td>'; 

						}
						echo '</table>';
					?>
					</div>
					</td>
					<td>&nbsp;</td>
					<td id="login" width="200px" style="text-align: justify" valign="top">
							<?php							if (!isset($_POST['submit']))							{   								 // Show the form    							 include 'register_form.inc.php';   							   	 exit;							}							else							{ 							    // Check if any of the fields are missing     							if (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['nick']))     							{          							// Reshow the form with an error          							$reg_error = 'No blanks allowed...';          							include 'register_form.inc.php';          							exit;     							}

								if (!is_numeric ($_POST['username']) || strlen($_POST['username']) != 16)								{									$reg_error = 'Your Console Number is invalid...';          							include 'register_form.inc.php';          							exit;								}

								if (!is_numeric ($_POST['friendcode']) || strlen($_POST['friendcode']) != 12)								{									$reg_error = 'Your Friend Code is invalid...';          							include 'register_form.inc.php';          							exit;								}

								$username = $_POST['username'];								$checkuser = mysql_query("SELECT username FROM user WHERE username='$username'");								$username_exist = mysql_num_rows($checkuser);								if($username_exist > 0)
								{   							    	$reg_error = "Console Number is currently used";									include 'register_form.inc.php';							    	exit;								}	     							// Everything is ok, register     							user_register ($_POST['username'], $_POST['password'], $_POST['nick'], $_POST['skill'], $_POST['character'], $_POST['country'], $_POST['friendcode']);								user_login($_POST['username'], $_POST['password']);     							echo '<script>							<!-- 								 window.location= "http://www.mariokartchallenger.com/index.php?act=game"							//-->							</script>';							}?>
